//
//  String+Format.swift
//  SwiftuiUno
//
//  Created by hccc on 2023/12/13.
//

import Foundation

infix operator =~
/// (正则操作, 左边参数为文本, 右边参数为表达式).
public func =~ (content: String, matchs: String) -> Bool {
    return Regex.match(matchs, content)
}

extension String {
    /// (是否为电子邮件).
    var isEmail: Bool {
        // http://stackoverflow.com/questions/25471114/how-to-validate-an-e-mail-address-in-swift
        self =~ "[A-Z0-9a-z._%+-\\u4e00-\\u9fa5]+@[A-Za-z0-9.-\\u4e00-\\u9fa5]+\\.[A-Za-z\\u4e00-\\u9fa5]{2,}"
    }
}
